/*
 * $Id$
 */

package corejs.expr;

import corejs.rt.ActivationRecord;
import corejs.rt.Value;
import corejs.stmt.Statement;
import corejs.util.XmlPrinter;

/**
 *
 * @author pengyu
 */
public class NameExpr implements Expression, Assignable {
  
   private String _text;

   public NameExpr(final String text) {
      _text = text;
   }

   public String name() {
      return _text;
   }

   @Override
   public Object eval(final ActivationRecord scope) {
      throw new UnsupportedOperationException();
   }

   @Override
   public void print(final XmlPrinter printer) {
      printer.print("name", _text);
   }

   @Override
   public String toString() {
      return _text;
   }

   @Override
   public Value accept(final ExpressionVisitor v) {
      return v.visitName(this);
   }

   @Override
   public Value acceptAssignment(final ExpressionVisitor v, 
                                  final Expression e) {
      return v.visitAssignment(_text, e);
   }
}
